package pkg.chemdrm;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.BoundCamera;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.ui.activity.BaseGameActivity;

import android.os.Bundle;





/* This is where the game starts. The scene built here will be the MenuScene even
 * though the activity extends a BaseGameActivity. The menu support in AndEngine is 
 * too restrictive for us to do the menu designed in the Start Menu Screen section
 * of the Design Docs.
 */
public class ChemicalDreamActivity extends BaseGameActivity {
	private final static float CAMERA_WIDTH = 480; // since we're holding the phone sideways.
	private final static float CAMERA_HEIGHT = 320;
	
	private BoundCamera mCamera;
	private Engine mEngine;
	
	private SceneHandler mSceneHandler;
	private ResourceHandler mResourceHandler;
	
	public void onLoadComplete() 
	{
		// called when loading is complete.
	}

	/*
	 * (non-Javadoc)
	 * @see org.anddev.andengine.ui.IGameInterface#onLoadEngine()
	 * 
	 * The RatioResolutionPolicy enforces a policy that states that any device we play this on, the ratio of the width to height
	 * specified here must remain the same. If there is any discrepancy in the physical dimensions of the device, it'll show
	 * the black bars on the sides.
	 */
	public Engine onLoadEngine() 
	{
		this.mCamera 	= new BoundCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
		mEngine 		= new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
		return mEngine;
	}

	public void onLoadResources() {
		// TODO Auto-generated method stub
		
	}

	public Scene onLoadScene() 
	{
		mResourceHandler = new ResourceHandler(mEngine, this);
		
		mSceneHandler 				= new SceneHandler(mEngine);
		MenuScene menuScene 		= new MenuScene(this, mSceneHandler, mResourceHandler, mCamera);
		GameScene gameScene			= new GameScene(this, mSceneHandler, mResourceHandler, mCamera);
		HelpScene helpScene			= new HelpScene(this, mSceneHandler, mResourceHandler, mCamera);
		ObjectiveScene oScene		= new ObjectiveScene(this, mSceneHandler, mResourceHandler, mCamera);
		MovementScene mScene		= new MovementScene(this, mSceneHandler, mResourceHandler, mCamera);
		AttackScene aScene			= new AttackScene(this,mSceneHandler,mResourceHandler, mCamera);
		
		mSceneHandler.addScene("MainMenu", 	menuScene);
		mSceneHandler.addScene("Game", 		gameScene);
		mSceneHandler.addScene("Help",		helpScene);
		mSceneHandler.addScene("Objective", oScene);
		mSceneHandler.addScene("Movement", mScene);
		mSceneHandler.addScene("Attack", aScene);
		
		return menuScene;
	}
}